package file;

import java.io.File;
import java.io.IOException;
@SuppressWarnings("all")
public class Create {
    public static void main(String[] args) throws IOException {
        System.out.println("创建文件");
        for (int i = 1; i <= 10; i++) {
            File file = new File("C:\\Users\\13175250825\\Desktop\\学学\\powerbyyjp\\src\\file\\test"+i+".txt");//src同目录 s =./
                    if (file.exists()){
            System.out.println("文件存在");
        }else {
            file.createNewFile();
        }
        }
        System.out.println("创建目录==============");
        for (int i = 1; i <= 1; i++) {
            File file = new File("C:\\Users\\13175250825\\Desktop\\学学\\powerbyyjp\\src\\file\\test"+i+"demo");
            if (file.exists()){
                System.out.println("文件存在");
            }else {
                file.mkdir();
            }
        }
        System.out.println("删除文件目录");//删除目录的时候 要保证是空目录，虽然还是能提示删除成功 但是实际上没有删除
        File file = new File("C:\\Users\\13175250825\\Desktop\\学学\\powerbyyjp\\src\\file\\test1.txt");
        if (file.exists()){
            file.delete();
            System.out.println("文件删了");
        }else {
            System.out.println("文件不存在");
        }
        File file1 = new File("C:\\Users\\13175250825\\Desktop\\学学\\powerbyyjp\\src\\file\\test1demo");
        if (file1.exists()){
            file1.delete();
            System.out.println("文件删了");
        }else {
            System.out.println("文件不存在");
        }
    }
}
